package com.example.demo1.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author sunjk
 * @since 2020/9/3
 */
@Configuration
public class RabbitConfig {

    /**
     * 队列1
     */
    @Bean(name = "message")
    Queue hellowQueue() {
        return new Queue("hello.message");
    }
    /**
     *队列2
     */
    @Bean(name = "messages")
    Queue topicQueue() {
        return new Queue("topic.hello.messages");
    }
    /**
     *队列2
     */
    @Bean(name = "messages")
    Queue Faueue() {
        return new Queue("topic.hello.messages");
    }

     /**
      * 交换机
      */
    @Bean
    TopicExchange exchange1() {
        return new TopicExchange("exchange");
    }

    /**
     *绑定
     */
    @Bean
    Binding bindings (@Qualifier("message")Queue queue, TopicExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("topic.hell");
    }

    /**
     * 绑定
     */
    @Bean
    Binding bindings1 (@Qualifier("messages")Queue queue, TopicExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("topic.*");
    }



}
